package com.example.springboottools.pic;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

public class ImgageBackgroupDector {
    public static boolean hasBackground(File imageFile) {
        try {
            BufferedImage image = ImageIO.read(imageFile);
            return image.getColorModel().hasAlpha();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return false;
    }

    public static void main(String[] args) {
        File imageFile = new File("C:\\Users\\SH102909\\Downloads\\createProducts (10)\\新建文件夹\\cn3000803138EA_1_xnl.jpg");
        boolean hasBackground = hasBackground(imageFile);
        System.out.println("Image has background: " + hasBackground);
    }

}
